package net.jsoft.pms.mapper.jcqd;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.github.pagehelper.Page;

@Mapper
public interface JcqdMapper
{
    @Select("SELECT distinct t.jc_mainlist_id,t.memo,t.group_id,t.creator,t.jc_state,t.CREATEDATE,t.EDITDATE,t.COPY_FLAG FROM HX_TOOLS.JCQD_MAINLIST t WHERE (CREATEDATE between TO_DATE('${start}','yyyy-MM-dd') and TO_DATE('${end}','yyyy-MM-dd') or EDITDATE between TO_DATE('${start}','yyyy-MM-dd') and TO_DATE('${end}','yyyy-MM-dd') )AND CREATOR IN (${opts}) ORDER BY CREATOR")
    List<Map<String, Object>> getJcqdList(@Param("start") String start, @Param("end") String end, @Param("opts") String opts);

    @Select("SELECT distinct t.jc_mainlist_id,t.memo,t.group_id,t.creator,t.jc_state,t.CREATEDATE,t.EDITDATE,t.COPY_FLAG FROM HX_TOOLS.JCQD_MAINLIST t WHERE t.jc_state = '3' and t.COPY_FLAG in ('0','2')  and   TO_DATE( substr(JC_TB_VERSION,0,8) ,'yyyyMMdd') between TO_DATE('${start}','yyyy-MM-dd') and TO_DATE('${end}','yyyy-MM-dd') AND CREATOR IN (${opts}) ORDER BY group_id ,CREATOR")
    List<Map<String, Object>> getJcqdVersoinNote(@Param("start") String start, @Param("end") String end, @Param("opts") String opts);

    @SelectProvider(type = JcptProvider.class, method = "getJcqdListByParams")
    Page<Map<String, Object>> getJcqdListByParams(@Param("sszb") String sszb, @Param("beginDate") final String beginDate, @Param("endDate") final String endDate,
            @Param("optUser") final String optUser, @Param("zt") final String zt, @Param("copyFlag") final String copyFlag, @Param("jcqdId") final String jcqdId);

    @Select("SELECT t.jc_mainlist_id,t.memo,t.group_id,t.creator,t.jc_state,t.CREATEDATE,t.EDITDATE,t.COPY_FLAG FROM HX_TOOLS.JCQD_MAINLIST t WHERE t.jc_mainlist_id = '${id}'")
    Map<String, Object> getJcqdByQdbh(@Param("id") String id);

}
